//
//  XLPersonCenterProxyViewController.m
//  XLPersonCenter
//
//  Created by 宋振 on 2018/7/19.
//  Copyright © 2018年 夜幕繁华. All rights reserved.
//

#import "XLPersonCenterProxyViewController.h"

/**
 告知是否滚动
 */
NSString *const personCenterProxyScrollNotification = @"personCenterProxyScrollNotification";

/**
 下拉刷新通知
 */
NSString *const personCenterProxyHeaderRefresh = @"personCenterProxyHeaderRefresh";

@interface XLPersonCenterProxyViewController ()

@end

@implementation XLPersonCenterProxyViewController

- (void)viewDidLoad {
    [super viewDidLoad];
    // Do any additional setup after loading the view.
}


#pragma mark    -   -   - UIScrollViewDelegate -    -   -

- (void)scrollViewDidScroll:(UIScrollView *)scrollView
{
    //判断是否可以滚动
    if (self.contentIsScroll == NO) {
        [scrollView setContentOffset:CGPointZero];
        return;
    }
    
    if (scrollView.contentOffset.y <= 0) {
        
        //设置不可滚动
        self.contentIsScroll = NO;
        [scrollView setContentOffset:CGPointZero];
        
        //告知滚动状态
        [[NSNotificationCenter defaultCenter] postNotificationName:personCenterProxyScrollNotification object:nil];
    }
}

#pragma mark    -   -   - 其他 -  -   -

/**
 根据使用场景 获取insets
 */
- (UIEdgeInsets)defaultContentScrollInsetsForScece:(XLPersonCenterProxy)XLPersonCenterProxy
{
    //获取当前手机宽高 用来判断是否是iphone X
    CGSize mainSize = [UIScreen mainScreen].bounds.size;
    
    CGFloat width = MIN(mainSize.width, mainSize.height);
    CGFloat height = MAX(mainSize.width, mainSize.height);
    
    BOOL currentIphoneX = (height==812.0&&width==375.0)?YES:NO;
    
    UIEdgeInsets edginset = UIEdgeInsetsZero;
    
    //根据选择 设置导航
    switch (XLPersonCenterProxy) {
        case XLPersonCenterProxyNone:
            break;
        case XLPersonCenterProxyNavigationBar:
            edginset.bottom = currentIphoneX ? (88.0+34.0) : 64.0;
            break;
        case XLPersonCenterProxyTabBar:
            edginset.bottom = currentIphoneX ? 83.0 : 49.0;
            break;
        case XLPersonCenterProxyAll:
            edginset.bottom = currentIphoneX ? (88.0+83.0) : (49.0+64.0);
            break;
    }
    
    return edginset;
}

/**
 滑动到顶部
 */
- (void)scrollViewToTop
{
    
}

/**
 下拉刷新
 */
- (void)beginHeaderRefresh
{
    [[NSNotificationCenter defaultCenter] postNotificationName:personCenterProxyHeaderRefresh object:nil];
}













- (void)didReceiveMemoryWarning {
    [super didReceiveMemoryWarning];
    // Dispose of any resources that can be recreated.
}



@end
